package com.bhs.sansonglogistics.ui.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.CouponBean;
import com.bhs.sansonglogistics.utils.MyUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class CouponAdapter extends BaseQuickAdapter<CouponBean, BaseViewHolder> {

    private int type;

    public CouponAdapter(int type) {
        super(type == 1 ? R.layout.item_coupon : R.layout.item_coupon2);
        this.type = type;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CouponBean item) {
        helper.addOnClickListener(R.id.tv_specification, R.id.tv_over);
        helper.setText(R.id.tv_money,MyUtils.subZeroAndDot(item.getCoupon_price())+"元");
        helper.setText(R.id.tv_money_Off,item.getCoupon_title());
        helper.setText(R.id.tv_hint,item.getCoupon_type_name());
        helper.setText(R.id.tv_hint,item.getCoupon_type_name());
        helper.setText(R.id.tv_period_validity,String.format("有效期至%s",item.getDate_end()));
        helper.setText(R.id.tv_aggregate_amount,String.format("发券总金额%s元",Integer.parseInt(MyUtils.subZeroAndDot(item.getCoupon_price()))*item.getCoupon_num()));
        helper.setText(R.id.tv_number,String.format("发券数量%s个",item.getCoupon_num()));
        helper.setText(R.id.tv_already_received,String.format("已领取%s张",item.getTakeNum()));
        helper.setText(R.id.tv_have_been_used,String.format("已使用%s张",item.getUsedNum()));
        helper.setText(R.id.tv_unclaimed,String.format("未领取%s张",item.getUnTakeNum()));
    }


}
